;;; +vcs.el --- vcs configurations

;;; Commentary:

;;; Code:

;; -------- A comprehensive visual interface to diff & patch --------
(use-package ediff
  :ensure nil
  :hook(;; show org ediffs unfolded
        (ediff-prepare-buffer . outline-show-all)
        ;; restore window layout when done
        (ediff-quit . winner-undo))
  :config
  (setq ediff-window-setup-function 'ediff-setup-windows-plain
        ediff-split-window-function 'split-window-horizontally
        ediff-merge-split-window-function 'split-window-horizontally))

;; -------- highlight uncommitted changes --------
(use-package diff-hl
  :defer t
  :diminish diff-hl-mode
  :if (executable-find "git")
  :hook
  ((after-init . global-diff-hl-mode)
   (dired-mode . diff-hl-dired-mode))
  :config
  (diff-hl-margin-mode)
  (setq diff-hl-side 'right))

;; -------- hightlight git config files --------
(add-to-list 'auto-mode-alist '("\\.gitignore\\|.gitmodules\\'" . conf-mode))

;; -------- (ma)git --------
(use-package magit
  :defer t
  :if (executable-find "git")
  :mode (("\\COMMIT_EDITMSG\\'" . text-mode)
         ("\\MERGE_MSG\\'" . text-mode))
  :init
  (setq magit-commit-ask-to-stage nil
        magit-diff-refine-hunk t)
  :config
  (setq magit-auto-revert-mode nil)
  :bind
  (("C-x g" . magit-status)))

(provide '+vcs)

;;; +vcs.el ends here
